import request from "@/utils/request";

// 获取编辑菜单页面信息
export const getEditMenuInfo = (id = -1) => {
  return request({
    method: "GET",
    // url: `/boss/menu/getEditMenuInfo?id=${id}`
    url: "/boss/menu/getEditMenuInfo",
    params: {
      id
    }
  });
};

// 添加菜单接口
export const createOrUpdateMenu = data => {
  return request({
    method: "POST",
    url: "/boss/menu/saveOrUpdate",
    data
  });
};

// 获取所有菜单
export const getAllMenus = () => {
  return request({
    method: "GET",
    url: "/boss/menu/getAll"
  });
};

// 删除菜单接口
export const deleteMenu = id => {
  return request({
    method: "DELETE",
    url: `/boss/menu/${id}`
  });
};

// 获取所有菜单并按层级展示
export const getMenuNodeList = () => {
  return request({
    method: "GET",
    url: "/boss/menu/getMenuNodeList"
  });
};

// 给角色分配菜单
export const allocateRoleMenus = data => {
  return request({
    method: "POST",
    url: "/boss/menu/allocateRoleMenus",
    data
  });
};

// 获取当前角色拥有的菜单列表接口
export const getRoleMenus = roleId => {
  return request({
    method: "GET",
    url: "/boss/menu/getRoleMenus",
    params: {
      roleId
    }
  });
};
